﻿using Microsoft.EntityFrameworkCore;

namespace MachineVision.Domain
{
    public static class EFExtension
    {
        public static void AddSeed(this ModelBuilder modelBuilder)
        {
            var now = new DateTime(2022, 9, 1, 0, 0, 0);

            modelBuilder.Entity<TemperatureInfo>().HasData(
                new TemperatureInfo() { Id = 1, CreateTime = now, TempTime = now, TemperatureC = 50, Description = "" }
                , new TemperatureInfo() { Id = 2, CreateTime = now, TempTime = now, TemperatureC = 55, Description = "" }
                , new TemperatureInfo() { Id = 4, CreateTime = now, TempTime = now, TemperatureC = 52, Description = "" }
            );

            modelBuilder.Entity<WarningInfo>().HasData(
                new WarningInfo {
                    Id = 1,
                    NO = "001",
                    CreateTime = now,
                    TerminalA = 10.00,
                    TerminalX = 11.00,
                    TerminalY = 12.00,
                    Time = now,
                    Type = WarningType.超温,
                }
            );
            modelBuilder.Entity<MissionHistoryInfo>().HasData(
                new MissionHistoryInfo
                {
                    Id = 1,
                    NO = "001",
                    CreateTime = now,
                    StartTime = now.AddMinutes(-1),
                    EndTime = now,
                    Name = "Demo任务",
                    Type = MissionType.视觉_测温,
                }
            );

            var guid = new Guid("4e9ae737-0105-49b5-8a0f-08173b01d77a");
            modelBuilder.Entity<PatrolGroup>().HasData(
                new PatrolGroup
                {
                    Id = 1,
                    CreateTime = now,
                    NO = "Test01",
                    Name = "测试组",
                    RoleId = guid,
                    //Cars = new List<PatrolCar> {
                    //        new PatrolCar{
                    //            Id=1, Name="car1", NO= "001", CreateTime= now ,
                    //        }
                    //     }
                });
            modelBuilder.Entity<PatrolCar>().HasData(
                new PatrolCar
                {
                    Id = 1,
                    Name = "car1",
                    NO = "001",
                    CreateTime = now,
                    GroupId = 1
                });
            //菜单
            modelBuilder.Entity<Menu>().HasData(
               new Menu
               {
                   SuperId = null,
                   Id = 1,
                   Name = "报警/历史",
                   Icon = "layui-Icon-time",
                   IsMain = true,
                   //Pages = new List<Menu>()
                   //{
                   //    new Menu { Id=11, Name = "报警信息", PageUrl = "report/warning.html", },
                   //    new Menu {  Id=12,Name = "任务历史", PageUrl = "report/history.html", },
                   //    //new Menu { Name = "温度监测", Icon = "layui-Icon-light", PageUrl = "temperature/templist.html", },
                   //}
               },
               new Menu
               {
                   SuperId = null,
                   Id = 2,
                   Name = "车辆监控",
                   Icon = "layui-Icon-camera",
                   IsMain = true,
                   //Pages = new List<Menu>()
                   // {
                   //     new Menu { Id=21, Name = "视频监控(标准流)", PageUrl = "videos/basicvideo.html", },// , Icon = "layui-Icon-console"
                   //     new Menu {  Id=22,Name = "视频监控(UIKIT)", PageUrl = "videos/uikitvideo.html", }
                   // }
               },
               new Menu
               {
                   SuperId = null,
                   Id = 3,
                   Name = "测试功能",
                   Icon = "layui-Icon-release",
                   IsMain = true,
                   //Pages = new List<Menu>()
                   //{
                   //    new Menu {  Id=31,Name = "测试页面",PageUrl = "test/test.html", }
                   //}
               },
               new Menu { Id = 11, Name = "报警信息", PageUrl = "report/warning.html",SuperId=1 },
               new Menu { Id = 12, Name = "任务历史", PageUrl = "report/history.html", SuperId = 1 },
               new Menu { Id = 21, Name = "视频监控(标准流)", PageUrl = "videos/basicvideo.html", SuperId = 2 },
               new Menu { Id = 22, Name = "视频监控(UIKIT)", PageUrl = "videos/uikitvideo.html", SuperId = 2 },
               new Menu { Id = 31, Name = "测试页面", PageUrl = "test/test.html", SuperId = 3 }
               );
        }

    }
}
